home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / Draw.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  65.2 KB  |  1,604 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    Draw.Lib
  5. #
  6. #    Contains:    Tasks to help do testing of drawing operations
  7. #
  8. #    Written by:    KTA, KL, ML, GS et al
  9. #
  10. #    Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    1.0.118>      5/1/96    MDF        Modified so that the SetTool() task can be         redirected
  19. #                                    through the gSetTool global variable.
  20. #    .0.117+>      5/1/96    MDF        Modified so that the SetTool() task can be redirected through
  21. #                                    the gSetTool global variable.
  22. #    1.0.117>      2/8/96    JC        
  23. #    1.0.117+>      2/8/96    JC        Changed all window .r (Rect) traits to .b (bound) traits and
  24. #                                    changed any window insets to reflect new bound rect.
  25. #    1.0.116>    11/29/95    ML        Draw - use RandomDrawObject to generate random         object
  26. #    .0.115+>    11/29/95    ML        Draw - use RandomDrawObject to generate random object
  27. #    1.0.115>    11/27/95    ML        Draw - update for gradients, background colors,         text
  28. #                                    colors, pet pats
  29. #    .0.114+>    11/27/95    ML        Draw - update for gradients, background colors, text colors, pet
  30. #                                    pats
  31. #    1.0.114>    11/10/95    ML        InitDraw() - Added support for gradients, background colors,
  32. #                                    text colors, and pen patterns.  CheckObjectStruct() - Object
  33. #                                    struct now has 9 elements.  SetAttributes() - removed elemNum -
  34. #                                    not used, now call SetObjectAttribute for each attribute.
  35. #                                    SetObjectAttribute() - created.  Object Structure Accessors() -
  36. #                                    Added support for gradients, background colors, and pen
  37. #                                    patterns.  Draw() - allow pThePointList to be user defineable.
  38. #                                    SetColor(), SetLine(), SetPattern() - Call SetPaletteItem.
  39. #                                    SetBackgroundColor(), SetTextColor(), SetPenPattern(),
  40. #                                    SetGradient(), SetPaletteItem(), RandomDrawObject() - created.
  41. #                                    Whew!
  42. #    .0.113+>     11/7/95    ML        Draw() - allow pThePointList to be user defineable.
  43. #    1.0.113>    12/12/94    ML        Removed gTargetCheck
  44. #    .0.112+>    12/12/94    ML        Removed gTargetCheck
  45. #    1.0.112>     12/1/94    ML        Added Error Handling Support
  46. #    .0.111+>     12/1/94    ML        Added Error Handling Support
  47. #    1.0.111>     7/18/94    KTA        CheckSetup() - changed the reporting so the current palette is 4
  48. #                                    elements it is global coordinates and if 5 it is relative to the
  49. #                                    specified window.
  50. #    1.0.110>      5/9/94    KTA        DrawObject() - Added gDrawObjectHook.
  51. #    <1.0.19>      5/2/94    KTA        Removed all references to kPullOffPal, kScrollPal.
  52. #    <1.0.18>     4/28/94    KTA        DrawObject() - Add TCS for drawing the object
  53. #    <1.0.17>     4/18/94    KTA        UseTool routines - Added Quotes to the pointlists (really).
  54. #    <1.0.16>     4/18/94    KTA        UseTool routines - Added Quotes to the pointlists.
  55. #    <1.0.15>     4/15/94    ML        add kDragOff to globals declaration in DrawObject()!
  56. #    <1.0.14>     3/17/94    KTA        Added support for kMenuItemPopUpPal palettes.
  57. #    <1.0.13>     3/16/94    KTA        Added kDragOff tool.
  58. #    <1.0.12>     3/16/94    KTA        New TCS set - kTCSetUseTool.
  59. #    <1.0.11>     3/16/94    KTA        Added TCS calls to UseTool routines.
  60. #    <1.0.10>     12/2/93    KTA        CheckObjectStruct() doesn't choke on kMultiClickDrag tools
  61. #                                    anymore.
  62. #     <1.0.9>    11/19/93    NAGA    Modify TCS format
  63. #     <1.0.8>     8/30/93    KTA        Updated task headers and parameters.
  64. #     <1.0.7>     8/25/93    KTA        Added support for parity checking the TCS stack.
  65. #     <1.0.6>      8/3/93    KTA        DrawObject()- Fixed bug where directCoord Tools weren't setting
  66. #                                    any attributes.
  67. #     <1.0.4>      6/8/93    NAGA    unmark tasks that are not published
  68. #        <2+>      6/8/93    NAGA    unmark tasks that are not published
  69. #        <1+>     5/21/93    NAGA    Adding header and porting old files to follow new standards
  70. #
  71. # ****************************************************************************
  72. #
  73.  
  74. ########################################################################
  75. #                            External libraries 
  76. #=======================================================================
  77. Libraries  "Palette.Lib", "String.Lib","OutPut.lib", "TCS.Lib", "Geometry.Lib",
  78. "UserInterface.Lib", "ExceptionHandling.Lib";
  79.  
  80. #########################################################################
  81. #                        InitDraw()
  82. #========================================================================
  83. # Author:        KTA
  84. # Description:    Initializes the Draw globals. 
  85. # Parameters:    None
  86. # Returns:        Nada
  87. # Examples:        InitDraw();
  88. # Assumptions:    
  89. #========================================================================
  90. # History:
  91. # ML 11/10/95    Added support for gradients, background colors, text colors,
  92. #                and pen patterns
  93. # JC  2/8/96    Changed "global gWindowInset := {0,20,20,20};" to "{0,0,20,20}".
  94. # MDF 04/29/96    Added task reference for SetTool.
  95. #########################################################################
  96. TASK InitDraw()
  97. begin
  98.     ##############  Task References   ############
  99.     global gSetTool                := Task SetTool;        # Requires VU 2.0
  100.     global gSetLine             := Task SetLine;        # Requires VU 2.0
  101.     global gSetColor             := Task SetColor;        # Requires VU 2.0
  102.     global gSetPattern             := Task SetPattern;        # Requires VU 2.0
  103.     global gSetGradient         := Task SetGradient;        # Requires VU 2.0
  104.     global gSetBackgroundColor     := Task SetBackgroundColor;        # Requires VU 2.0
  105.     global gSetTextColor        := Task SetTextColor;        # Requires VU 2.0
  106.     global gSetPenPattern         := Task SetPenPattern;        # Requires VU 2.0
  107.  
  108.     ############## Tool Type Defines  ############
  109.     global kClick                 := 1;
  110.     global kDrag                 := 2;
  111.     global kDragClick             := 3;
  112.     global kMultiDrag            := 4;
  113.     global kMultiClick             := 5;
  114.     global kMultiClickDrag         := 6;
  115.     global kDragOff                 := 7;
  116.  
  117.     ############## Palette Type Defines  ########
  118.     global kPalDocWind             := 1;
  119.     global kPalWind             := 2;
  120.     global kPopUpPal             := 3;
  121.     global kMenuItemPopUpPal     := 4;
  122.  
  123.     ############## Script Contants  ############
  124.     global gWindowInset         := {0,0,20,20};        # Inset to wind to get content region
  125.     global gScreenInset         := {0,20,0,0};            # Inset to screen
  126.     global gBoundingRect         := {};                    # 
  127.     global gVoidRect             := {};                    # Rect not to draw in - coordinates should be RelativeToWindow
  128.     global gLineWeights         := {};                    # Line Weights
  129.     global gNumPoints            := 6;                    # Number of points for all multipoint tools
  130.     global gDrawObject            := 0;                    # Object Number in a given suite (incremented by DrawObject)
  131. end;
  132.  
  133. #########################################################################
  134. #            CheckObjectStruct(pObjectStruct)
  135. #========================================================================
  136. # Author:        KTA
  137. # Description:    Check validity of elements in pObjectStruct.
  138. # Parameters:    pObjectStruct -     the objectStruct to check
  139. # Returns:        0 - objectStruct is hosed
  140. #                1 - objectStruct is OK
  141. # Example:    returnVal := CheckObjectStruct(pObjectStruct);
  142. #========================================================================
  143. # History:
  144. # KTA    12/01/93    kMultiClickDrag tools weren't supported added 
  145. #                    elemType <= 6 (bug #1117685)
  146. # KTA    3/16/94    Added KDragOff tools which requires support of elemType = 7
  147. # ML    11/10/95 Object struct now has 9 elements
  148. #########################################################################
  149. TASK CheckObjectStruct(pObjectStruct)
  150. begin
  151.     if (global gDebugFlag)
  152.         println "----- CheckObjectStruct() - Draw.lib --------";
  153.     global gNumPoints;
  154.     returnVal := 1;
  155.     
  156.     if not(Card(pObjectStruct) = 9)
  157.     begin
  158.         Println "!@#$% CheckObjectFailure - Card(pObjectStruct) - ", Card(pObjectStruct);
  159.         returnVal := 0;
  160.     end;
  161.     
  162.     ## Tool Struct
  163.     elemStruct    := GetElemStruct(pObjectStruct);
  164.     if not(Card(elemStruct) = 6)
  165.     begin
  166.         Println "!@#$% CheckObjectFailure - Card(elemStruct) - ", Card(elemStruct);
  167.         returnVal := 0;
  168.     end;
  169.  
  170.     ## ToolType
  171.     elemType := GetElemType(elemStruct);
  172.     if not (elemStruct = 'Random')
  173.     begin
  174.         if not((elemType >= 0) and (elemType <= 7) )
  175.         begin
  176.             Println "!@#$% CheckObjectFailure - elemType - ", ElemType;
  177.             returnVal := 0;
  178.         end;
  179.     end;
  180.     
  181.     ## Tool Name
  182.     elemName := GetElemName(elemStruct);
  183.     if not (elemStruct = 'Random')
  184.     begin
  185.         if not( TypeOf(elemName) = "string" )
  186.         begin
  187.             Println "!@#$% CheckObjectFailure - elemName - ", elemName;
  188.             returnVal := 0;
  189.         end;
  190.     end;
  191.     
  192.     ## DoubleClick
  193.     elemDblClk := GetElemDblClk(elemStruct);
  194.     if not (elemStruct = 'Random')
  195.     begin
  196.         if not((elemDblClk = 0) or (elemDblClk = 1) )
  197.         begin
  198.             Println "!@#$% CheckObjectFailure - elemDblClk - ", elemDblClk;
  199.             returnVal := 0;
  200.         end;
  201.     end;
  202.     
  203.     ## Pointlist
  204.     pointList := GetPointList(pObjectStruct);
  205.     if (global gDebugFlag)
  206.         println "This is the pointlist",pointList;
  207.     (*    
  208.     if not((Card(pointList) = gNumPoints) or (Card(pointList) = elemType))
  209.     begin
  210.         Println "!@#$% CheckObjectFailure - pointList - ",  pointList;
  211.         returnVal := 0;
  212.     end;
  213.  
  214.     ## Line
  215.     theLine    := GetLine(pObjectStruct);
  216.     if not((TypeOF(theLine) = "list") and (Card(theLine) = 3) or (theLine = 0))
  217.     begin
  218.         Println "!@#$% CheckObjectFailure - theLine - ", theLine;
  219.         returnVal := 0;
  220.     end;
  221.  
  222.     ## Color
  223.     theCol := GetColor(pObjectStruct);
  224.     if not((TypeOF(theCol) = "list") and (Card(theCol) = 3) or (theCol = 0))
  225.     begin
  226.         Println "!@#$% CheckObjectFailure - theCol - ", theCol;
  227.         returnVal := 0;
  228.     end;
  229.     
  230.     ## Pattern
  231.     thePat := GetPattern(pObjectStruct);
  232.     if not((TypeOF(thePat) = "list") and (Card(thePat) = 3) or (thePat = 0))
  233.     begin
  234.         Println "!@#$% CheckObjectFailure - thePat - ", thePat;
  235.         returnVal := 0;
  236.     end;
  237. *)
  238.     if (global gDebugFlag) # Set gDebugFlag to TRUE to output variables for debugging 
  239.     begin
  240.         Println "======= DebugStr - CheckObject() in Draw.Lib ======";
  241.         Println "    pObjectStruct - ", {pObjectStruct};
  242.         Println "    elemStruct - ", {elemStruct};
  243.         Println "    elemType - ", {elemType};
  244.         Println "    elemName - ", {elemName};
  245.         Println "    elemDblClk - ", {elemDblClk};
  246.         Println "    pointList - ", {pointList};
  247.     end;
  248.  
  249.     return returnVal;
  250. end;    # CheckObjectStruct()
  251.  
  252. #########################################################################
  253. #                DrawObject(pObjectStruct, pSpecifier)
  254. #========================================================================
  255. # Author:        DMM / KTA
  256. # Description:    Main routine in the Draw Libraries.  Calls all subroutines
  257. #                necessary to draw a given object, passing the appropriate 
  258. #                elements from the pObjectStruct input param.
  259. # Parameters:    pObjectStruct :=     {
  260. #                                    {ToolStruct},
  261. #                                    {PointList},
  262. #                                    {PatternStruct}, 
  263. #                                    {LineStruct},
  264. #                                    {ColorStruct}
  265. #                                    };
  266. #                pSpecifier - Specifies the window (or Rect) to draw in)
  267. # Returns:        1 - exercises went OK
  268. #                0 - error in drawing object
  269. # Examples:    noError := DrawObject(objectStruct,specifier);
  270. # DrawObject({global SelectTool, {{25,15}}, {12,2 ,’Pattern’}, 0, ‘Random’});
  271. #========================================================================
  272. # History:
  273. # KTA    8/3/92 Fixed bug where directCoord Tools weren't setting any attributes
  274. # ml    4/14/94    Add global kDragOff to globals declaration
  275. # KTA    4/28/94    Added TCS for drawing the object
  276. # KTA    5/9/94    Added gDrawObjectHook
  277. # ML    12/12/94 Removed gTargetcheck
  278. # MDF    04/29/96    Changed calls to SetTool into calls to gSetTool.
  279. #########################################################################
  280. TASK DrawObject(pObjectStruct := {}, pSpecifier := 0) begin
  281.     global kClick, kDrag, kDragOff, kDragClick, kMultiDrag, kMultiClickDrag,
  282.     kMultiClick,gToolsThatUseLineWeight, gDrawObject;
  283.     gDrawObject := gDrawObject + 1;  # Increment the object number for TCS info
  284.     TempMouse := MouseSpeed(5);
  285.     failStr := '';
  286.     
  287.     if (global gDebugFlag)
  288.         println "----- DrawObject() - Draw.lib --------";
  289.     
  290.     ## Call accessors to access object struct
  291.     ToolStruct    := GetElemStruct(pObjectStruct);
  292.     if (ToolStruct = 'Random')
  293.     begin    
  294.         pObjectStruct := InsertElemStruct(call(global gSetTool,ToolStruct,0),pObjectStruct); # insert a random one but don't select it.
  295.         ToolStruct    := GetElemStruct(pObjectStruct);
  296.         if (global gDebugFlag)
  297.             println "----- This is the ObjectStruct after inserting Toolstruct -", pObjectStruct;
  298.     end;
  299.     elemPalNum := GetPalNum(ToolStruct);
  300.     elemType := GetElemType(ToolStruct);
  301.     elemName := GetElemName(ToolStruct);
  302.     elemDblClk := GetElemDblClk(ToolStruct);
  303.     elemNum := GetElemNum(ToolStruct); 
  304.     SetAttributeFlag := GetSetAttribute(ToolStruct);
  305.  
  306.     pointList := SetPointList(pObjectStruct, pSpecifier);
  307.     pObjectStruct := InsertPointList(pointList, pObjectStruct);
  308.  
  309.     returnVal := CheckObjectStruct(pObjectStruct); #
  310.     if (returnVal) 
  311.     begin
  312.         if (TypeOf(elemPalNum) = 'list')    ## Handle Coordinate tools
  313.             returnVal := PalettePicker(ToolStruct);
  314.         else
  315.             call(global gSetTool,ToolStruct,,gDrawObject);
  316.         ###########################################################
  317.         #### Call to set object attributes and update pObjectStruct
  318.         ###########################################################
  319.         if(not(SetAttributeFlag) or ((Typeof(SetAttributeFlag) = 'string') and (Card(GetAttributes(ToolStruct)) = 1)))
  320.         begin
  321.             pObjectStruct := InsertPattern(0, pObjectStruct);    # Insert NIL patternStruct
  322.             pObjectStruct := InsertColor(0, pObjectStruct);        # Insert NIL ColorStruct
  323.             pObjectStruct := InsertLine(0, pObjectStruct);        # Insert NIL LineStruct
  324.         end;
  325.         else if(SetAttributeFlag = 1)
  326.             pObjectStruct := SetAttributes(pObjectStruct,gDrawObject);
  327.     
  328.         if(elemType)    # Tool Type is zero because we don't want to draw an object
  329.         begin
  330.             # inform the user of the object we are going to draw
  331.             pointStr := PointListToStr(pointList);            # put pointList into a string
  332.             str := "-- Drawing object defined by points {pointStr}";
  333.             if (elemType = kClick) 
  334.                 LogStr(Str);
  335.             else 
  336.             begin
  337.                 # inform user of actions to take place before/during/after each move
  338.                 if ((elemType = kDrag) or (elemType = kMultiDrag))
  339.                     LogStr("{str} Will hold mouse down during move");
  340.                 else if (elemType = kMultiClickDrag)
  341.                     LogStr("{str} Will hold mouse down during each move and release at each destination point");
  342.                 else if (elemType = kMultiClick)
  343.                     LogStr("{str} Will click at each point");
  344.             end;
  345.         
  346.             temp := global gDisableAllLogging;
  347.             if not(global gDebugFlag)
  348.                 gDisableAllLogging := 1;
  349.         
  350.             # Call the UseTool Routines
  351.             if (elemType = kClick)
  352.                 returnVal := UseClickTool(pointList,pSpecifier);
  353.                 else if (elemType = kDrag) 
  354.                     returnVal := UseDragTool( pointList, pSpecifier, ,elemDblClk );
  355.                     else if (elemType = kDragClick) 
  356.                         returnVal := UseDragClickTool( pointList, pSpecifier, ,elemDblClk );
  357.                         else if (elemType = kMultiDrag)
  358.                             returnVal := UseMultiDragTool( pointList, pSpecifier, elemDblClk );
  359.                             else if (elemType = kMultiClick)
  360.                                 returnVal := UseMultiClickTool( pointList, pSpecifier, elemDblClk );
  361.                                 else if (elemType = kMultiClickDrag)
  362.                                     returnVal := UseMultiClickDragTool( pointList, pSpecifier, elemDblClk );
  363.                                     else if (elemType = kDragOff) 
  364.                                         returnVal := UseDragOffTool( pointList, pSpecifier, ,elemDblClk );
  365.                                         else begin
  366.                                             LogStr("No tool function declared for tool type {elemType}");
  367.                                             returnVal := 0;
  368.                                         end;
  369.             gDisableAllLogging := temp;
  370.         end;
  371.         else
  372.             Println "Tool Type for this tool is 0, so no object drawn.";
  373.         
  374.         TCSStart({ 2, global kTCSetDraw },"Draw Object");        # Start TCS
  375.         
  376.         isDialog := DialogCheck('',1,,[window o:1 s:Dialog]!);
  377.         if (isDialog)        # Check for any dialogs
  378.         begin
  379.             returnVal := 0;
  380.             TCReturnVal := 0;
  381.             failStr := "!@#$% Failed to draw object" + ' / ' + isDialog;
  382.             LogStr(failStr);
  383.         end;
  384.         else if (returnVal)
  385.         begin
  386.             if(SetAttributeFlag = 2) or (Typeof(SetAttributeFlag) = 'string')
  387.                 pObjectStruct := SetAttributes(pObjectStruct,gDrawObject);
  388.             ### To handle text entry
  389.             if(Typeof(SetAttributeFlag) = 'string')
  390.                 TypeStr(SetAttributeFlag);
  391.                 
  392.             isDialog := DialogCheck('',1,,[window o:1 s:Dialog]!);
  393.             if (isDialog)        # Check for any dialogs
  394.             begin
  395.                 returnVal := 0;
  396.                 TCReturnVal := 0;
  397.                 failStr := "!@#$% Failed to draw object" + ' / ' + isDialog;
  398.                 LogStr(failStr);
  399.             end;
  400.             else
  401.             begin
  402.                 LogStr("----- Finished drawing object -----");
  403.                 returnVal := pObjectStruct;
  404.                 TCReturnVal := 1;
  405.             end;
  406.         end;
  407.         
  408.         TCSEnd({ 2, global kTCSetDraw },TCReturnVal,failStr,,"'{pObjectStruct}'");
  409.     end;    
  410.  
  411.     if(global gDrawObjectHook)
  412.         call(gDrawObjectHook);
  413.         
  414.     Println "¶ theObject  - ", returnVal;
  415.     println "-----------------------------------";
  416.     println ;
  417.     MouseSpeed(TempMouse);
  418.      return(returnVal);
  419. end; # DrawObject()
  420.  
  421. #########################################################################
  422. #                SetAttributes(pObjectStruct,pDrawObject)
  423. #========================================================================
  424. # Author:        KTA
  425. # Description:    This task takes a complete objectStruct as a parameter, it will
  426. #                determine if the tool being used to draw with can set various
  427. #                attributes (patterns, lines, and colors).  If so the appropriate
  428. #                tasks will be called and the actual attribute structs used will
  429. #                be inserted into the objectStruct prior to returning.
  430. # Parameters:    pObjectStruct - a complete objectStruct - note some elements will
  431. #                                evaluate to 0 or random upon entry - the random 
  432. #                                elements will be replaced with actual atribute  
  433. #                                struct prior to exiting. Elements that are 0 will
  434. #                                not be set.
  435. #                pDrawObject -     This is the number that is used to tie together
  436. #                                all elements that make up an object for TCS  
  437. #                                logging purposes.
  438. # Returns:    pObjectStruct  - Setting attributes went OK
  439. #            0 - error in - Setting attributes
  440. # Examples:    
  441. #========================================================================
  442. # History:
  443. # ML 11/09/95 removed elemNum - not used.
  444. # ML 11/09/95 now call SetObjectAttribute for each attribute
  445. #########################################################################
  446. TASK SetAttributes(pObjectStruct, pDrawObject)
  447. begin
  448.     global gSetPattern, gSetLine, gSetColor, gSetGradient, gSetBackgroundColor,
  449.                 gSetTextColor, gSetPenPattern;
  450.                 
  451.     elemStruct    := GetElemStruct(pObjectStruct);
  452.     
  453.     ###########################################################
  454.     #### Call to set object attributes and update pObjectStruct
  455.     ###########################################################
  456.     
  457.     ##### SetPattern ######
  458.         pObjectStruct := SetObjectAttribute(pObjectStruct, elemStruct, pDrawObject,
  459.                                 task GetPatternFlag, task GetPattern,
  460.                                 gSetPattern, task InsertPattern, "pattern");
  461.     ##### SetLine ###### 
  462.         pObjectStruct := SetObjectAttribute(pObjectStruct, elemStruct, pDrawObject,
  463.                                 task GetLineFlag, task GetLine,
  464.                                 gSetLine, task InsertLine, "Line");
  465.     
  466.     ##### SetColor ######
  467.         pObjectStruct := SetObjectAttribute(pObjectStruct, elemStruct, pDrawObject,
  468.                                 task GetColorFlag, task GetColor,
  469.                                 gSetColor, task InsertColor, "Color");
  470.     
  471.     ##### SetGradient ######
  472.         pObjectStruct := SetObjectAttribute(pObjectStruct, elemStruct, pDrawObject,
  473.                                 task GetGradientFlag, task GetGradient,
  474.                                 gSetGradient, task InsertGradient, "Gradient");
  475.     
  476.     ##### SetBackgroundColor ######
  477.         pObjectStruct := SetObjectAttribute(pObjectStruct, elemStruct, pDrawObject,
  478.                                 task GetBackgroundColorFlag, task GetBackgroundColor,
  479.                                 gSetBackgroundColor, task InsertBackgroundColor,
  480.                                 "Background Color");
  481.     
  482.     ##### gSetTextColor ######
  483.         pObjectStruct := SetObjectAttribute(pObjectStruct, elemStruct, pDrawObject,
  484.                                 task GetTextColorFlag, task GetTextColor,
  485.                                 gSetTextColor, task InsertTextColor,
  486.                                 "Text Color");
  487.     
  488.     ##### gSetPenPattern ######
  489.         pObjectStruct := SetObjectAttribute(pObjectStruct, elemStruct, pDrawObject,
  490.                                 task GetPenPatternFlag, task GetPenPattern,
  491.                                 gSetPenPattern, task InsertPenPattern,
  492.                                 "Pen Pattern");
  493.     
  494.     return(pObjectStruct);
  495. end;    # SetAttributes()
  496.  
  497. #########################################################################
  498. #                SetObjectAttribute(pObjectStruct,pDrawObject)
  499. #========================================================================
  500. # Author:        ML
  501. # Description:    Sets an objects attribute and returns the updated object structure.
  502. # Parameters:    pObjectStruct - a complete objectStruct - note some elements will
  503. #                                evaluate to 0 or random upon entry - the random 
  504. #                                elements will be replaced with actual atribute  
  505. #                                struct prior to exiting. Elements that are 0 will
  506. #                                not be set.
  507. #                pDrawObject -     This is the number that is used to tie together
  508. #                                all elements that make up an object for TCS  
  509. #                                logging purposes.
  510. # Returns:    pObjectStruct  - Setting attributes went OK
  511. #            0 - error in - Setting attributes
  512. # Examples:    
  513. #========================================================================
  514. # History:
  515. #########################################################################
  516. task SetObjectAttribute(pObjectStruct, pElemStruct, pDrawObject, pFlagTask,
  517.                         pGetAttributeTask, pSetAttributeTask, pInsertAttributeTask,
  518.                         pAttributeName)
  519. begin
  520.     if(call(pFlagTask, pElemStruct))
  521.     begin
  522.         theAttribute := call(pGetAttributeTask, pObjectStruct);
  523.         if (theAttribute)
  524.         begin
  525.             theAttributeStruct :=  Call(pSetAttributeTask, theAttribute,,pDrawObject);
  526.             pObjectStruct := call(pInsertAttributeTask, theAttributeStruct, pObjectStruct);
  527.         end;
  528.         if (global gDebugFlag)
  529.             println "This is the pObjectStruct after SetObjectAttribute {pAttributeName} - ", pObjectStruct;
  530.     end;
  531.     else
  532.     begin
  533.         if (global gDebugFlag)
  534.             LogStr("This is not a {pAttributeName} tool");
  535.         pObjectStruct := call(pInsertAttributeTask, 0, pObjectStruct);
  536.     end;
  537.     return (pObjectStruct);
  538. end;
  539.  
  540. #########################################################################
  541. #                            UseClickTool()
  542. #========================================================================
  543. # Author:        DMM 
  544. # Description:    Move to point and click once.
  545. # Parameters:    pPointList - List containing a point.
  546. #                pSpecifier - Window specifier for the window to move relative to.
  547. # Returns:        1 - Clicked
  548. # Examples:        UseClickTool();
  549. # Assumptions:    None 
  550. #========================================================================
  551. # History:
  552. # KTA 4/18/94  Added Quotes to the pointlist
  553. #########################################################################
  554. TASK UseClickTool(pPointList, pSpecifier) 
  555. begin
  556.     global gDrawObject;
  557.     if (global gDebugFlag)
  558.         println "----- UseClickTool() - Draw.lib --------";
  559.     
  560.     TCSStart({ 1, global kTCSetUseTool },"Use Click tool");        # Start TCS
  561.     
  562.     thePt := pPointList[1];                # get first point
  563.     returnVal := MoveRelativeToWindow(thePt[1],thePt[2],pSpecifier, 2);    # move to the first point 
  564.     
  565.     if(returnVal)        # MoveRelativeToWindow returns global coordinates and we want a success/Failure flag
  566.         returnVal := 1;
  567.         
  568.     thePointList := "'{pPointList}'";
  569.     TCSEnd({ 1, global kTCSetUseTool }, returnVal,,gDrawObject,thePointList);
  570.     
  571.     return(returnVal);
  572. end;
  573.  
  574. #########################################################################
  575. #            UseDragTool(pPointList, pSpecifier, pMouseDown, pDClickToEnd)
  576. #========================================================================
  577. # Author:        DMM 
  578. # Description:    Drag from the current location.
  579. # Parameters:    pPointList - Point to move to.
  580. #                pSpecifier - Window specifier in which to drag in.
  581. #                pMouseDown - 0 - don't hold mouse key down while moving
  582. #                            1 - press mouse key down - move - release
  583. #                            2 - Click after moving - no mouse down during move
  584. #                            3 - press mouse key down - move - don't release
  585. #                            4 - move - release
  586. #                pDClickToEnd - Boolean flag indicating whether or not to double
  587. #                                click the mouse after dragging.
  588. # Returns:        returnVal - what moveRelativeToWindow returns.
  589. # Examples:        UseDragTool({{100,200},{200,200}}, 0, 1,0);
  590. # Assumptions:    All points are specified relative to window.
  591. #========================================================================
  592. # History:
  593. # KTA 4/18/94  Added Quotes to the pointlist
  594. # ML 12/1/94    Added Error Handling Support
  595. #########################################################################
  596. TASK UseDragTool(pPointList:= {}, pSpecifier := 0, pMouseDown := 6, pDClickToEnd := 0) 
  597. begin
  598.     global gDrawObject;
  599.     returnVal := 0;
  600.     if (global gDebugFlag)
  601.         println "----- UseDragTool() - Draw.lib --------";
  602.     TCSStart({ 2, global kTCSetUseTool },"Use Drag tool");        # Start TCS
  603.     
  604.     returnVal := MoveRelativeToWindow( pPointList ,, pSpecifier,pMouseDown);
  605.     if (pDClickToEnd) begin    # doubleClick to end sequence
  606.         _doubleClick();
  607.         #LogStr("Double-clicked the mouse button to end drawing sequence");
  608.     end;
  609.     
  610.     if(returnVal)        # MoveRelativeToWindow returns global coordinates and we want a success/Failure flag
  611.         returnVal := 1;
  612.     
  613.     thePointList := "'{pPointList}'";
  614.     TCSEnd({ 2, global kTCSetUseTool }, returnVal,,gDrawObject,thePointList);
  615.  
  616.     return(returnVal);
  617. end;
  618.  
  619. #########################################################################
  620. #    UseDragClickTool(pPointList, pSpecifier, pMouseDown, pDClickToEnd)
  621. #========================================================================
  622. # Author:        KTA 
  623. # Description:    Drag from the current location. Then click at a different point.
  624. # Parameters:    pPointList - List of points to move to.
  625. #                pSpecifier - Window specifier in which to drag in.
  626. #                pMouseDown - 0 - don't hold mouse key down while moving
  627. #                            1 - press mouse key down - move - release
  628. #                            2 - Click after moving - no mouse down during move
  629. #                            3 - press mouse key down - move - don't release
  630. #                            4 - move - release
  631. #                pDClickToEnd - Boolean flag indicating whether or not to double
  632. #                                click the mouse after dragging.
  633. # Returns:        returnVal - what MoveRelativeToWindow returns.
  634. # Examples:        UseDragClickTool({{100,200},{100,200}, {200,300}},0,1,0);
  635. # Assumptions:    All points are specified relative to window.
  636. #========================================================================
  637. # History:
  638. # KTA 4/18/94 Added Quotes to the pointlist
  639. # ML 12/1/94    Added Error Handling Support
  640. #########################################################################
  641. TASK UseDragClickTool(pPointList:= {}, pSpecifier := 0, pMouseDown := 1, pDClickToEnd := 0)
  642. begin
  643.     global gDrawObject;
  644.     if (global gDebugFlag)
  645.     begin
  646.         println "----- UseDragClickTool() - Draw.lib --------";
  647.         println "pPointList - ", pPointList;
  648.     end;
  649.     OriginalPointlist := pPointList;
  650.     TCSStart({ 5, global kTCSetUseTool },"Use Drag-Click tool");        # Start TCS
  651.     
  652.     thePt := pPointList[1];                # get first point
  653.     MoveRelativeToWindow(thePt[1],thePt[2],pSpecifier);    # move to the first point and set relativeFlag
  654.     pPointList := remove(1,pPointList);  # remove first point from list - we already used it
  655.     
  656.     returnVal := 0;
  657.     dragPt := pPointList[1];
  658.     clickPt := pPointList[2];
  659.  
  660.     dragH := dragPt[1];
  661.     dragV := dragPt[2];
  662.     clickH := clickPt[1];
  663.     clickV := clickPt[2];
  664.  
  665.     returnVal := MoveRelativeToWindow( dragH , dragV , pSpecifier, pMouseDown);
  666.     returnVal := MoveRelativeToWindow( clickH ,clickV , pSpecifier, 2);
  667.     
  668.     if (pDClickToEnd) 
  669.         _doubleClick();
  670.     
  671.     if(returnVal)        # MoveRelativeToWindow returns global coordinates and we want a success/Failure flag
  672.         returnVal := 1;
  673.  
  674.  
  675.     thePointList := "'{OriginalPointlist}'";
  676.     TCSEnd({ 5, global kTCSetUseTool }, returnVal,,gDrawObject,thePointList);
  677.  
  678.     return(returnVal);
  679. end; # UseDragClickTool()
  680.  
  681. #########################################################################
  682. #            UseMultiDragTool(pPointList, pSpecifier, pDClickToEnd)
  683. #========================================================================
  684. # Author:        DMM 
  685. # Description:    mouseDown-drag-drag-drag-drag-release.
  686. # Parameters:    pPointList - List of points to move to.
  687. #                pSpecifier - Window specifier in which to drag in.
  688. #                pDClickToEnd - Boolean flag indicating whether or not to double
  689. #                                click the mouse after dragging.
  690. # Returns:        returnVal - what MoveRelativeToWindow returns.
  691. # Examples:        UseMultiDragTool({{100,200}, {200,300}},0,0);
  692. # Assumptions:    All points are specified relative to window.
  693. #========================================================================
  694. # History:
  695. # KTA 4/18/94 Added Quotes to the pointlist
  696. # ML 12/1/94    Added Error Handling Support
  697. #########################################################################
  698. TASK UseMultiDragTool(pPointList := {}, pSpecifier := 0, pDClickToEnd := 0) 
  699. begin
  700.     global gDrawObject;
  701.     if (global gDebugFlag)
  702.         println "----- UseMultiDragTool() - Draw.lib --------";
  703.     
  704.     TCSStart({ 3, global kTCSetUseTool },"Use MultiDrag tool");        # Start TCS
  705.     returnVal := MoveRelativeToWindow( pPointList ,, pSpecifier,6);
  706.     
  707.     if (pDClickToEnd) 
  708.         _doubleClick();
  709.     
  710.     if(returnVal)        # MoveRelativeToWindow returns global coordinates and we want a success/Failure flag
  711.         returnVal := 1;
  712.         
  713.     thePointList := "'{pPointList}'";
  714.     TCSEnd({ 3, global kTCSetUseTool }, returnVal,,gDrawObject,thePointList);
  715.  
  716.     return(returnVal);
  717. end;
  718.  
  719. #########################################################################
  720. #        UseMultiClickTool(pPointList, pSpecifier, pDClickToEnd)
  721. #========================================================================
  722. # Author:        DMM 
  723. # Description:    click-move-click-move….
  724. # Parameters:    pPointList - List of points to move to.
  725. #                pSpecifier - Window specifier in which to drag in.
  726. #                pDClickToEnd - Boolean flag indicating whether or not to double
  727. #                                click the mouse after dragging.
  728. # Returns:        returnVal - what MoveRelativeToWindow returns.
  729. # Examples:        UseMultiClickTool({{100,200}, {200,300}},0,0);
  730. # Assumptions:    All points are specified relative to window.
  731. #========================================================================
  732. # History:
  733. # KTA 4/18/94 Added Quotes to the pointlist
  734. # ML 12/1/94    Added Error Handling Support
  735. #########################################################################
  736. TASK UseMultiClickTool(pPointList, pSpecifier := 0, pDClickToEnd := 0) 
  737. begin
  738.     global gDrawObject;
  739.     if (global gDebugFlag)
  740.         println "----- UseMultiClickTool() - Draw.lib --------";
  741.  
  742.     TCSStart({ 4, global kTCSetUseTool },"Use MultiClick tool");        # Start TCS
  743.  
  744.     returnVal := MoveRelativeToWindow( pPointList ,, pSpecifier, 5);
  745.     
  746.     if (pDClickToEnd) 
  747.         _doubleClick();
  748.     
  749.     if(returnVal)        # MoveRelativeToWindow returns global coordinates and we want a success/Failure flag
  750.         returnVal := 1;
  751.  
  752.  
  753.     thePointList := "'{pPointList}'";
  754.     TCSEnd({ 4, global kTCSetUseTool }, returnVal,,gDrawObject,thePointList);
  755.     
  756.     return(returnVal);
  757. end;
  758.  
  759. #########################################################################
  760. #    UseMultiClickDragTool(pPointList, pSpecifier, pDClickToEnd)
  761. #========================================================================
  762. # Author:        KTA 
  763. # Description:    mouseDown-drag-mouseUp-mouseDown-drag-mouseUp….
  764. # Parameters:    pPointList - List of points to move to.
  765. #                pSpecifier - Window specifier in which to drag in.
  766. #                pDClickToEnd - Boolean flag indicating whether or not to double
  767. #                                click the mouse after dragging.
  768. # Returns:        Nothing
  769. # Examples:        UseMultiClickDragTool();
  770. # Assumptions:    All points are
  771. #                 specified relative to window.
  772. #========================================================================
  773. # History:
  774. # KTA 4/18/94  Added Quotes to the pointlist
  775. # ML 12/1/94    Added Error Handling Support
  776. #########################################################################
  777. TASK UseMultiClickDragTool(pPointList, pSpecifier := 0, pDClickToEnd := 0) 
  778. begin
  779.     global gDrawObject;
  780.     if (global gDebugFlag)
  781.         println "----- UseMultiClickDragTool() - Draw.lib --------";
  782.     oldMouseSpeed := mouseSpeed(4);    # slow down mouse
  783.     mouseDown := 4;
  784.     
  785.     TCSStart({ 6, global kTCSetUseTool },"Use MultiClickDrag tool");        # Start TCS
  786.  
  787.     OriginalPointlist := pPointList;
  788.     thePt := pPointList[1];                # get first point
  789.     MoveRelativeToWindow(thePt[1],thePt[2],pSpecifier);    # move to the first point and set relativeFlag
  790.     pPointList := remove(1,pPointList);  # remove first point from list - we already used it
  791.     
  792.     for each PairPts in pPointList
  793.     begin
  794.         xCoord := PairPts[1];
  795.         yCoord := PairPts[2];
  796.         returnVal := MoveRelativeToWindow( xCoord ,yCoord, pSpecifier,1);
  797.     end;
  798.  
  799.         
  800.     mouseSpeed(oldMouseSpeed);        # restore mouse speed
  801.     if (pDClickToEnd) 
  802.         _doubleClick();
  803.     
  804.     if(returnVal)        # MoveRelativeToWindow returns global coordinates and we want a success/Failure flag
  805.         returnVal := 1;
  806.         
  807.     thePointList := "'{OriginalPointlist}'";
  808.     TCSEnd({ 6, global kTCSetUseTool }, returnVal,,gDrawObject,thePointList);
  809.     Return(returnVal);
  810. end;
  811.  
  812. #########################################################################
  813. #            UseDragOffTool(pPointList, pSpecifier, pMouseDown, pDClickToEnd)
  814. #========================================================================
  815. # Author:        KTA 
  816. # Description:    Drag Tool into the content region of the window.
  817. # Parameters:    pPointList - Point to move to.
  818. #                pSpecifier - Window specifier in which to drag in.
  819. #                pMouseDown - 0 - don't hold mouse key down while moving
  820. #                            1 - press mouse key down - move - release
  821. #                            2 - Click after moving - no mouse down during move
  822. #                            3 - press mouse key down - move - don't release
  823. #                            4 - move - release
  824. #                pDClickToEnd - Boolean flag indicating whether or not to double
  825. #                                click the mouse after dragging.
  826. # Returns:        returnVal - what moveRelativeToWindow returns.
  827. # Examples:        UseDragOffTool({{100,200}}, 0, 1,0);
  828. # Assumptions:    All points are specified relative to window.
  829. #========================================================================
  830. # History:
  831. # KTA 4/18/94  Added Quotes to the pointlist
  832. # ML 12/1/94    Added Error Handling Support
  833. #########################################################################
  834. TASK UseDragOffTool(pPointList:= {}, pSpecifier := 0, pMouseDown := 1, pDClickToEnd := 0) 
  835. begin
  836.     global gDrawObject;
  837.     returnVal := 0;
  838.     if (global gDebugFlag)
  839.         println "----- UseDragOffTool() - Draw.lib --------";
  840.     TCSStart({ 7, global kTCSetUseTool },"Use DragOff tool");        # Start TCS
  841.     
  842.     returnVal := MoveRelativeToWindow( pPointList ,, pSpecifier,pMouseDown);
  843.     if (pDClickToEnd) begin    # doubleClick to end sequence
  844.         _doubleClick();
  845.         #LogStr("Double-clicked the mouse button to end drawing sequence");
  846.     end;
  847.     
  848.     if(returnVal)        # MoveRelativeToWindow returns global coordinates and we want a success/Failure flag
  849.         returnVal := 1;
  850.     
  851.     thePointList := "'{pPointList}'";
  852.     TCSEnd({ 7, global kTCSetUseTool }, returnVal,,gDrawObject,thePointList);
  853.  
  854.     return(returnVal);
  855. end; # UseDragOffTool()
  856.  
  857. #########################################################################
  858. #                            Object Structure Accessors()
  859. #========================================================================
  860. # Author:        DMM 
  861. # Description:    These functions access the data in an objectStruct data 
  862. #                structure.
  863. # Parameters:    objectStruct
  864. # Returns:        the requested data element or list
  865. #========================================================================
  866. # History:
  867. # ML    11/10/95    Added support for gradients, background colors, text colors,
  868. #                    and pen patterns
  869. #########################################################################
  870. ## objectStruct is the data structure that completely specifies the object to be drawn
  871. ##            objectStruct    {
  872. ##                ElemStruct
  873. ##                PointList
  874. ##                Pattern
  875. ##                Line
  876. ##                Color
  877. ##            }
  878.  
  879. task GetElemStruct(objectStruct)         begin return( objectStruct[1] );    end;
  880. task GetPointList(objectStruct)            begin return( objectStruct[2] );    end;
  881. task GetPattern(objectStruct)            begin return( objectStruct[3] );    end;
  882. task GetLine(objectStruct)                begin return( objectStruct[4] );    end;
  883. task GetColor(objectStruct)                begin return( objectStruct[5] );    end;
  884. task GetGradient(objectStruct)            begin return( objectStruct[6] );    end;
  885. task GetBackgroundColor(objectStruct)    begin return( objectStruct[7] );    end;
  886. task GetTextColor(objectStruct)            begin return( objectStruct[8] );    end;
  887. task GetPenPattern(objectStruct)        begin return( objectStruct[9] );    end;
  888.  
  889. task InsertElemStruct(tS, oS)        begin return( replace( tS,  1, oS ));    end;
  890. task InsertPointList(pts, oS)        begin return( replace( pts, 2, oS ));    end;
  891. task InsertPattern(pat, oS)            begin return( replace( pat, 3, oS ));    end;
  892. task InsertLine(lin, oS)            begin return( replace( lin, 4, oS ));    end;
  893. task InsertColor(col, oS)            begin return( replace( col, 5, oS ));    end;
  894. task InsertGradient(col, oS)        begin return( replace( col, 6, oS ));    end;
  895. task InsertBackgroundColor(col, oS)    begin return( replace( col, 7, oS ));    end;
  896. task InsertTextColor(col, oS)        begin return( replace( col, 8, oS ));    end;
  897. task InsertPenPattern(col, oS)        begin return( replace( col, 9, oS ));    end;
  898.  
  899.  
  900. #########################################################################
  901. #        MakePointList( pInset, pSpecifier, pNumPoints, pClosed, pVoidRect )
  902. #========================================================================
  903. # Author:        DMM
  904. # Description:    Generates a list of random points 
  905. # Parameters:    pInset -     inset into window for ppoints to be generated.
  906. #                pSpecifier - Window specifier for the window to generate points in.
  907. #                pNumPoints -    number of points to comprise the object
  908. #                pClosed     -     1 for closed object (first-last point the same)
  909. #                            0 for open object (first-last point different)
  910. #                pVoidRect - no points in object should be in this rectangle 
  911. # Returns:        List of Points.
  912. # Examples:        theObject := MakePointList(rect);    # 4 point closed object
  913. #                theObject := MakePointList(theWindow.r, 4,1,thePalette.r);
  914. #========================================================================
  915. # History:
  916. #
  917. # JC  2/8/96    Changed "pInset :={ 0,20,20,20 }" to "{0,0,20,20}".
  918. ########################################################################
  919. TASK MakePointList(pInset :={ 0,0,20,20 } , pSpecifier := 0, pNumPoints := global gNumPoints,  pClosed := 0, pVoidRect := {} ) 
  920. begin
  921.     if (global gDebugFlag)
  922.         println "----- MakePointList() - Draw.lib --------";
  923.     global gWindowInset, gVoidRect,gNumPoints, gBoundingRect;
  924.     # To help assure drawing occurs in the content region
  925.     if (gBoundingRect)                        # Window Rect
  926.         boundingRect := gBoundingRect;
  927.     else 
  928.         boundingRect := pSpecifier;
  929.         
  930.     if (gWindowInset)                        # Window inset
  931.         pInset := gWindowInset;
  932.     if (gVoidRect)                            # No points will be in this rect - 
  933.         pVoidRect := gVoidRect;                # Coordinates should be relative to window
  934.     pointList := GetRandomPointsRelativeToWindow(pInset, boundingRect,pNumPoints);
  935.     if (pNumPoints = 1)        # When only one set of point is required
  936.         pointlist := { pointlist };
  937.  
  938.     # Last point is same as first
  939.     if(pClosed)
  940.         pointList := replace(pointList[1], pNumPoints, pointList );
  941.     
  942.     # only points that are not in the void rectangle
  943.     if (pVoidRect) 
  944.     begin
  945.         for x := 1 to (pNumPoints - pClosed)     # last point will equal first if closed is true
  946.         begin
  947.             while (PtInRect(pointList[x],pVoidRect)) 
  948.             begin
  949.                 thePointh := pointList[x][1];
  950.                 thePointv := pointList[x][2];
  951.                 if (global gDebugFlag)
  952.                     Println "{thePointh},{thePointv} is in the void rect - get another point";
  953.                 thePoint := GetRandomPointsRelativeToWindow(pInset, boundingRect);
  954.                 if (thePoint) pointList := replace(thePoint, x, pointList );
  955.                 else LogStr("GetRandomPointsRelativeToWindow() hosed");
  956.             end;
  957.         end;
  958.     end;
  959.     
  960.     return( pointList );
  961. end; # MakePointList()
  962.  
  963.  
  964. #########################################################################
  965. #                    SetTool(pTool,pSelectTool, pObjectNumber)
  966. #========================================================================
  967. # Author:        KTA 
  968. # Description:    This task takes a ToolStruct as a parameter. If the ToolStruct
  969. #                evaluates to 'Random' a ToolStruct will be generated randomly.
  970. #                If the pSelectTool evaluates to true the tool will also be selected.
  971. #                Otherwise, the generated toolStruct will be returned without 
  972. #                selecting the tool. 
  973. # Parameters:    pTool - 0 - nothing done return 0
  974. #                        - Valid ToolStruct
  975. #                        - 'Random' - generates a random ToolStruct
  976. #                pSelectTool - Boolean flag which indicates whether or not to 
  977. #                            select the tool.
  978. #                pObjectNumber - Integer used to track all elements that make up 
  979. #                                an object - TCS related.
  980. # Returns:        0 - nothing done 0 passed in.
  981. #                Valid toolStruct 
  982. # Assumptions:    All draw related data structures set up properly.
  983. #========================================================================
  984. # History:
  985. #
  986. #########################################################################
  987. TASK SetTool(pTool := 'Random', pSelectTool := 1, pObjectNumber := 0)
  988. begin
  989.     if (global gDebugFlag)
  990.     begin
  991.         Println "++++++++ SetTool() has just been called++++++++ ";
  992.         Println "This is the toolStruct - ",pTool;
  993.     end;
  994.     global gToolList;
  995.     if(pTool)
  996.     begin
  997.         if(pTool = 'Random')
  998.         begin
  999.             toolNum := Random(1,card(gToolList));
  1000.             pTool := gToolList[toolNum];
  1001.             #theObject := InsertElemStruct(pTool, theObject); # Insert the tool description
  1002.             if (global gDebugFlag)
  1003.                 println "    pTool after generating a random one in SetTool() - ", pTool;
  1004.         end;
  1005.         if (pSelectTool)
  1006.         begin
  1007.             PalettePicker(pTool,pObjectNumber);
  1008.             # This is where we put a hook for Dragging tools after selecting
  1009.         end;
  1010.     end;
  1011.     return(pTool);
  1012. end;
  1013.  
  1014. #########################################################################
  1015. #                        GenerateObject(pTheObject)
  1016. #========================================================================
  1017. # Author:        KTA
  1018. # Description:    This task generates valid elements for any element that evaluates
  1019. #                to 'Random'. 
  1020. # Parameters:    pTheObject - A complete Object Struct.  The default is to 
  1021. #                            generate all elements of the returned object
  1022. #                            randomly. Passing in partially completed object
  1023. #                            struct will replace the elements which evaluate
  1024. #                            to 'Random' with valid data.
  1025. # Returns:        pTheObject - a complete objectStruct no elements will evaluate
  1026. #                            to 'Random'
  1027. # Examples:        GenerateObject({global PointerTool,'Random',0,'Random','Random'})
  1028. # Assumptions:    All the necessary Draw Structs have been defined correctly.
  1029. #========================================================================
  1030. # History:
  1031. #
  1032. #########################################################################
  1033. TASK GenerateObject(pTheObject := {'Random','Random','Random','Random','Random'}) 
  1034. begin
  1035.     if (global gDebugFlag)
  1036.         Println "----- GenerateObject() - Draw.lib --------";
  1037.  
  1038.     theTool := GetElemStruct(pTheObject);
  1039.     if (theTool = 'Random')
  1040.         theTool := SetTool(theTool, 0);
  1041.     pTheObject := InsertElemStruct(theTool,pTheObject);
  1042.     
  1043.     thePointList := GetPointList(pTheObject);
  1044.     if (thePointList = 'Random')
  1045.         thePointList := SetPointList(pTheObject);
  1046.     pTheObject := InsertPointList(thePointList, pTheObject);
  1047.  
  1048.     thePattern := GetPattern(pTheObject);
  1049.     if (thePattern = 'Random')
  1050.         thePattern := SetPattern(thePattern, 0);
  1051.     pTheObject := InsertPattern(thePattern,pTheObject);
  1052.  
  1053.     theLine := GetLine(pTheObject);
  1054.     if (theline = 'Random')
  1055.         theLine := SetLine(theLine, 0);
  1056.     pTheObject := InsertLine(theLine,pTheObject);
  1057.  
  1058.     theColor := GetColor(pTheObject);
  1059.     if (theColor = 'Random')
  1060.         theColor := SetColor(theColor, 0);
  1061.     pTheObject := InsertColor(theColor,pTheObject);
  1062.  
  1063.         Return(pTheObject);
  1064. end; # GenerateObject()
  1065.  
  1066. #########################################################################
  1067. #                        SetPointList(pTheObject, pSpecifier)
  1068. #========================================================================
  1069. # Author:        KTA 
  1070. # Description:    Determines the number of points required for a given tool type.
  1071. #                Then calls MakePointList() to generate pointlist for different
  1072. #                tool types.
  1073. #                    kClick tools - require a single point.
  1074. #                    kDrag tools - require a two points.
  1075. #                    All multipoint tools - access the global gNumPoints to 
  1076. #                        determine the number of points.
  1077. # Parameters:    pTheObject - a complete objectStruct with atleast a valid
  1078. #                            ToolStruct. 
  1079. #                pSpecifier - Specifier of the window in which to generate 
  1080. #                             points in.
  1081. # Returns:        thePointList - a list of point within <pSpecifier>
  1082. # Examples:        SetPointList(TheObjectStruct, 0);
  1083. # Assumptions:    All the necessary Draw Structs have been defined correctly.
  1084. #========================================================================
  1085. # History:
  1086. #
  1087. #########################################################################
  1088. TASK SetPointList(pTheObject, pSpecifier := 0)
  1089. begin
  1090.     global gNumPoints;
  1091.     if (global gDebugFlag)
  1092.         Println "++++++++ SetPointList() has just been called++++++++ ";
  1093.     theTool := GetElemStruct(pTheObject);
  1094.     thePointList := GetPointList(pTheObject);
  1095.     if(theTool)
  1096.     begin
  1097.         if (thePointList)
  1098.         begin
  1099.             if(thePointList = 'Random')
  1100.             begin
  1101.                 elemType := GetElemType(theTool);
  1102.                 if(elemType)
  1103.                 begin
  1104.                     # Create a point list and insert into the object structure 
  1105.                     # The number of points depends on the tool
  1106.                     elemType := GetElemType(theTool);
  1107.                     if (elemType <= 3) numPoints := elemType; # Click - pointlist will be 1/drag - pointlist will be 2
  1108.                     else if(elemType = 7) numPoints := 1;    # KDragOff tools only needs 1 point.
  1109.                     else numPoints := gNumPoints;
  1110.                     
  1111.                     thePointList := MakePointList(,pSpecifier,numPoints);
  1112.                 end;
  1113.                 else
  1114.                     thePointList := 0;
  1115.             end;
  1116.         end;
  1117.     end;
  1118.     else
  1119.         println "Sorry, can't generate a pointlist unless a tool has been defined";
  1120.         
  1121.     return(thePointList);
  1122. end; # SetPointList()
  1123.  
  1124. #########################################################################
  1125. #    Draw(pTheTool, pThePointList, pThePattern, pTheLine, pTheColor, pSpecifier )
  1126. #========================================================================
  1127. # Author:        KTA
  1128. # Description:    This task provides a means for defining any of the elements
  1129. #                within an ObjectStruct and allowing the libraries to generate
  1130. #                any element that evaluates to 'Random' (default for all elements)
  1131. # Parameters:    1 parameter for each of the elements of an objectStruct and 
  1132. #                1 additional parameter for the window pSpecifier.
  1133. #                    pTheTool - ToolStruct
  1134. #                    pThePointList - PointList (not user definable at this time)
  1135. #                    pThePattern - PatternStruct
  1136. #                    pTheLine - LineStruct
  1137. #                    pTheColor - ColorStruct
  1138. #                    pSpecifier - Window or rect to draw in 
  1139. # Returns:        The actual ObjectStruct after generating 'Random' elements.
  1140. # Examples:        Draw(Global SelectTool, ‘Random’,0,0,{14,3, ‘Color’})
  1141. # Assumptions:    All the necessary Draw Structs have been defined correctly.
  1142. #========================================================================
  1143. # History:
  1144. # ML 11/7/95    allow pThePointList to be user defineable.
  1145. # ML 11/27/95    add support for gradients, background colors, text colors, pet pats
  1146. # ML 11/29/95    use RandomDrawObject to generate random object
  1147. #########################################################################
  1148. TASK Draw(pTheTool := 'Random', pThePointList := 'Random', pThePattern := 'Random',
  1149.             pTheLine := 'Random', pTheColor := 'Random', pSpecifier := 0,
  1150.             pGradient := 'Random', pBGColor := 'Random', pTextColor := 'Random',
  1151.             pPenPat := 'Random')
  1152. begin
  1153.     theObject := RandomDrawObject();
  1154.  
  1155.     if not(pTheTool = 'Random')
  1156.         theObject := InsertElemStruct(pTheTool, theObject);
  1157.  
  1158.     if not(pThePointList = 'Random')    # We want to generate all pointlists for now KTA 7/92
  1159.         theObject := InsertPointList(pThePointList, theObject);
  1160.  
  1161.     if not(pThePattern = 'Random')
  1162.         theObject := InsertPattern(pThePattern, theObject);
  1163.  
  1164.     if not(pTheLine = 'Random')
  1165.         theObject := InsertLine(pTheLine, theObject);
  1166.  
  1167.     if not(pTheColor = 'Random')
  1168.         theObject := InsertColor(pTheColor, theObject);
  1169.  
  1170.     if not(pGradient = 'Random')
  1171.         theObject := InsertGradient(pGradient, theObject);
  1172.  
  1173.     if not(pBGColor = 'Random')
  1174.         theObject := InsertBackgroundColor(pBGColor, theObject);
  1175.  
  1176.     if not(pTextColor = 'Random')
  1177.         theObject := InsertTextColor(pTextColor, theObject);
  1178.  
  1179.     if not(pPenPat = 'Random')
  1180.         theObject := InsertPenPattern(pPenPat, theObject);
  1181.  
  1182.     theObject := DrawObject(theObject, pSpecifier);
  1183.     return(theObject);
  1184. end;
  1185.  
  1186. #########################################################################
  1187. #                SetColor(pTheColor, pSelectColor, pObjectNumber)
  1188. #========================================================================
  1189. # Author:        KTA
  1190. # Description:    This is used when selecting colors from a palette.This task
  1191. #                takes a ColorStruct as a parameter. If the ColorStruct evaluates
  1192. #                to 'Random' a ColorStruct will be generated randomly.
  1193. #                If the pSelectColor evaluates to true the color will also be selected.
  1194. #                Otherwise, the generated ColorStruct will be returned without 
  1195. #                selecting the color.  
  1196. # Parameters:    pTheColor - 0 - nothing done return 0
  1197. #                        - Valid ColorStruct
  1198. #                        - 'Random' - generates a random ColorStruct
  1199. #                pSelectColor - Boolean flag which indicates whether or not to 
  1200. #                            select the Color.
  1201. #                pObjectNumber - Integer used to track all elements that make up 
  1202. #                                an object - TCS related.
  1203. # Returns:        colStruct - A valid ColorStruct
  1204. # Examples:        SetColor('Random', 1, 14);
  1205. # Assumptions:    All draw related data structures set up properly.
  1206. #========================================================================
  1207. # History:
  1208. # ML 11/09/95    Call SetPaletteItem    
  1209. #########################################################################
  1210. TASK SetColor(pTheColor := 'Random', pSelectColor := 1, pObjectNumber := 0)    
  1211. begin
  1212.     return SetPaletteItem(pTheColor, pSelectColor, "Color", global kColorPaletteNum,
  1213.         pObjectNumber);    
  1214. end; # SetColor()
  1215.  
  1216.  
  1217. #########################################################################
  1218. #                    SetLine(pTheLine, pSelectLine, pObjectNumber)
  1219. #========================================================================
  1220. # Author:        KTA
  1221. # Description:    This is used when selecting line weights from a palette. 
  1222. #                This task takes a LineStruct as a parameter. If the LineStruct
  1223. #                evaluates to 'Random' a LineStruct will be generated randomly.
  1224. #                If the pSelectLine evaluates to true the line will also be selected.
  1225. #                Otherwise, the generated LineStruct will be returned without 
  1226. #                selecting the line weight.
  1227. # Parameters:    pTheLine - 0 - nothing done return 0
  1228. #                        - Valid LineStruct
  1229. #                        - 'Random' - generates a random LineStruct
  1230. #                pSelectLine - Boolean flag which indicates whether or not to 
  1231. #                            select the line.
  1232. #                pObjectNumber - Integer used to track all elements that make up 
  1233. #                                an object - TCS related.
  1234. # Returns:        LineStruct - A valid LineStruct
  1235. # Examples:        SetLine('Random', 1, 14);
  1236. # Assumptions:    All draw related data structures set up properly.
  1237. #========================================================================
  1238. # History:
  1239. # ML 11/09/95    Call SetPaletteItem    
  1240. #########################################################################
  1241. TASK SetLine(pTheLine := 'Random', pSelectLine := 1, pObjectNumber := 0) 
  1242. begin
  1243.     return SetPaletteItem(pTheLine, pSelectLine, "Line", global kLinePaletteNum,
  1244.         pObjectNumber);    
  1245. end; # SetLine()
  1246.  
  1247. #########################################################################
  1248. #                    SetLineMenuItems(pTheLine, pSelectLine, pObjectNumber)
  1249. #========================================================================
  1250. # Author:        KTA
  1251. # Description:    This is used when selecting line weights from menuItems. 
  1252. #                This task takes a LineStruct as a parameter. If the LineStruct
  1253. #                evaluates to 'Random' a LineStruct will be generated randomly.
  1254. #                If the ppSelectLine evaluates to true the tool will also be selected.
  1255. #                Otherwise, the generated LineStruct will be returned without 
  1256. #                selecting the line weight.  This task depends upon a global
  1257. #                gLineWeights to be defined as the menuItem titles of the menuitems
  1258. #                which are used to set line wieghts.
  1259. # Parameters:    pTheLine - 0 - nothing done return 0
  1260. #                        - Valid LineStruct
  1261. #                        - 'Random' - generates a random LineStruct
  1262. #                pSelectLine - Boolean flag which indicates whether or not to 
  1263. #                            select the line.
  1264. #                pObjectNumber - Integer used to track all elements that make up 
  1265. #                                an object - TCS related.
  1266. # Returns:        LineStruct - A valid LineStruct
  1267. # Examples:        SetLine('Random', 1, 14);
  1268. # Assumptions:    All draw related data structures set up properly.
  1269. #========================================================================
  1270. # History:
  1271. # KTA    8/24/93        TCS stack parity check
  1272. #########################################################################
  1273. TASK SetLineMenuItems(pTheLine := {}, pSelectLine := 1,  pObjectNumber := 0) 
  1274. begin
  1275.     failStr := '';
  1276.     if (global gDebugFlag)
  1277.         println "++++++++ SetLine() has just been called++++++++ ";
  1278.     global gLineWeights;
  1279.     if(pTheLine) 
  1280.     begin    
  1281.         # If a weight is not passed then calculate a random one
  1282.         if(pTheLine = 'Random')                        # Random Line wieght    
  1283.         begin
  1284.             whichWeight := random(1, Card(gLineWeights));    # Calculate which random weight to use
  1285.             TheLineWeight := gLineWeights[whichWeight];        # Set variable to actual weight
  1286.             pTheLine := { TheLineWeight, "Menu Item", "Line"};
  1287.             #theObject := InsertLine(lineStruct, theObject); 
  1288.         end;
  1289.         else
  1290.             TheLineWeight := pTheLine[1];
  1291.         
  1292.         
  1293.         if(TheLineWeight) and (pSelectLine)
  1294.         begin
  1295.             TCSStart({ 1, global kTCSetDraw },"SetLineMenuItems");        # Start TCS
  1296.             returnVal := SelectMenuItem(TheLineWeight);            # Select it
  1297.             if (returnVal)
  1298.                 returnVal := 1;
  1299.             else
  1300.             begin
  1301.                 failStr := "Failed to select menu item for line weight";
  1302.                 LogStr(failStr);
  1303.             end;
  1304.             TCSEnd({ 1, global kTCSetDraw },returnVal,failStr,pObjectNumber,TheLineWeight);
  1305.         end;
  1306.     end;
  1307.     else
  1308.         LogStr("Null object passed to SetLine");
  1309.     return(pTheLine);
  1310. end; # SetLineMenuItems()
  1311.  
  1312. #########################################################################
  1313. #            SetPattern(pThePattern, pSelectPattern, pObjectNumber)
  1314. #========================================================================
  1315. # Author:        KTA
  1316. # Description:    This is used when selecting patterns from a palette. 
  1317. #                This task takes a PatternStruct as a parameter. If the PatternStruct
  1318. #                evaluates to 'Random' a PatternStruct will be generated randomly.
  1319. #                If the pSelectPattern evaluates to true the pattern will also be selected.
  1320. #                Otherwise, the generated PatternStruct will be returned without 
  1321. #                selecting the pattern.
  1322. # Parameters:    pThePattern - 0 - nothing done return 0
  1323. #                            - Valid PatternStruct
  1324. #                            - 'Random' - generates a random PatternStruct
  1325. #                pSelectPattern - Boolean flag which indicates whether or not to 
  1326. #                            select the pattern.
  1327. #                pObjectNumber - Integer used to track all elements that make up 
  1328. #                                an object - TCS related.
  1329. # Returns:        patStruct - A valid PatternStruct
  1330. # Examples:        SetPattern('Random', 1, 14);
  1331. # Assumptions:    All draw related data structures set up properly.
  1332. #========================================================================
  1333. # History:
  1334. # ML 11/09/95    Call SetPaletteItem    
  1335. #########################################################################
  1336. TASK SetPattern(pThePattern := 'Random', pSelectPattern := 1, pObjectNumber := 0)    
  1337. begin
  1338.     return SetPaletteItem(pThePattern, pSelectPattern, "Pattern", global kPatternPaletteNum,
  1339.         pObjectNumber);    
  1340. end; # SetPattern()
  1341.  
  1342. #########################################################################
  1343. #            SetBackgroundColor(pBackgroundColor, pSelectItem, pObjectNumber)
  1344. #========================================================================
  1345. # Author:        ML
  1346. # Description:    This is used when selecting Background Colors from a palette. 
  1347. #                This task takes an element struct, item number, or "Random"
  1348. #                as a parameter.  If 'Random', an element struct will be generated randomly.
  1349. #                If pSelectItem evaluates to true the element struct
  1350. #                will also be selected.
  1351. # Parameters:    pBackgroundColor    - 0 - nothing done return 0
  1352. #                                    - Valid Item Num
  1353. #                                    - valid element struct
  1354. #                                    - 'Random' - generates a random element struct
  1355. #                pSelectItem - Boolean flag which indicates whether or not to 
  1356. #                            select the element.
  1357. #                pObjectNumber - Integer used to track all elements that make up 
  1358. #                                an object - TCS related.
  1359. # Returns:        BackgroundColorStruct - A valid BackgroundColorStruct
  1360. # Examples:        SetBackgroundColor('Random', 1, 14);
  1361. # Assumptions:    All draw related data structures set up properly.
  1362. #========================================================================
  1363. # History:
  1364. #########################################################################
  1365. TASK SetBackgroundColor(pBackgroundColor := 'Random', pSelectItem := 1,
  1366.                             pObjectNumber := 0)    
  1367. begin
  1368.     return SetPaletteItem(pBackgroundColor, pSelectItem, "Background Color",
  1369.             global kBackgroundColorPaletteNum, pObjectNumber);    
  1370. end; # SetBackgroundColor()
  1371.  
  1372. #########################################################################
  1373. #            SetTextColor(pTextColor, pSelectItem, pObjectNumber)
  1374. #========================================================================
  1375. # Author:        ML
  1376. # Description:    This is used when selecting Text Colors from a palette. 
  1377. #                This task takes an element struct, item number, or "Random"
  1378. #                as a parameter.  If 'Random', an element struct will be generated randomly.
  1379. #                If pSelectItem evaluates to true the element struct
  1380. #                will also be selected.
  1381. # Parameters:    pTextColor    - 0 - nothing done return 0
  1382. #                                    - Valid Item Num
  1383. #                                    - valid element struct
  1384. #                                    - 'Random' - generates a random element struct
  1385. #                pSelectItem - Boolean flag which indicates whether or not to 
  1386. #                            select the element.
  1387. #                pObjectNumber - Integer used to track all elements that make up 
  1388. #                                an object - TCS related.
  1389. # Returns:        TextColorStruct - A valid TextColorStruct
  1390. # Examples:        SetTextColor('Random', 1, 14);
  1391. # Assumptions:    All draw related data structures set up properly.
  1392. #========================================================================
  1393. # History:
  1394. #########################################################################
  1395. TASK SetTextColor(pTextColor := 'Random', pSelectItem := 1,
  1396.                             pObjectNumber := 0)    
  1397. begin
  1398.     return SetPaletteItem(pTextColor, pSelectItem, "Text Color",
  1399.             global kTextColorPaletteNum, pObjectNumber);    
  1400. end; # SetTextColor()
  1401.  
  1402. #########################################################################
  1403. #            SetPenPattern(pPenPattern, pSelectItem, pObjectNumber)
  1404. #========================================================================
  1405. # Author:        ML
  1406. # Description:    This is used when selecting pen patterns from a palette. 
  1407. #                This task takes an element struct, item number, or "Random"
  1408. #                as a parameter.  If 'Random', an element struct will be generated randomly.
  1409. #                If pSelectItem evaluates to true the element struct
  1410. #                will also be selected.
  1411. # Parameters:    pPenPattern    - 0 - nothing done return 0
  1412. #                                    - Valid Item Num
  1413. #                                    - valid element struct
  1414. #                                    - 'Random' - generates a random element struct
  1415. #                pSelectItem - Boolean flag which indicates whether or not to 
  1416. #                            select the element.
  1417. #                pObjectNumber - Integer used to track all elements that make up 
  1418. #                                an object - TCS related.
  1419. # Returns:        PenPatternStruct - A valid PenPatternStruct
  1420. # Examples:        SetPenPattern('Random', 1, 14);
  1421. # Assumptions:    All draw related data structures set up properly.
  1422. #========================================================================
  1423. # History:
  1424. #########################################################################
  1425. TASK SetPenPattern(pPenPattern := 'Random', pSelectItem := 1,
  1426.                             pObjectNumber := 0)    
  1427. begin
  1428.     return SetPaletteItem(pPenPattern, pSelectItem, "Pen Pattern",
  1429.             global kPenPatternPaletteNum, pObjectNumber);    
  1430. end; # SetPenPattern()
  1431.  
  1432. #########################################################################
  1433. #            SetGradient(pGradient, pSelectItem, pObjectNumber)
  1434. #========================================================================
  1435. # Author:        ML
  1436. # Description:    This is used when selecting gradients from a palette. 
  1437. #                This task takes an element struct, item number, or "Random"
  1438. #                as a parameter.  If 'Random', an element struct will be generated randomly.
  1439. #                If pSelectItem evaluates to true the element struct
  1440. #                will also be selected.
  1441. # Parameters:    pGradient    - 0 - nothing done return 0
  1442. #                                    - Valid Item Num
  1443. #                                    - valid element struct
  1444. #                                    - 'Random' - generates a random element struct
  1445. #                pSelectItem - Boolean flag which indicates whether or not to 
  1446. #                            select the element.
  1447. #                pObjectNumber - Integer used to track all elements that make up 
  1448. #                                an object - TCS related.
  1449. # Returns:        GradientStruct - A valid GradientStruct
  1450. # Examples:        SetGradient('Random', 1, 14);
  1451. # Assumptions:    All draw related data structures set up properly.
  1452. #========================================================================
  1453. # History:
  1454. #########################################################################
  1455. TASK SetGradient(pGradient := 'Random', pSelectItem := 1,
  1456.                             pObjectNumber := 0)    
  1457. begin
  1458.     return SetPaletteItem(pGradient, pSelectItem, "Gradients",
  1459.             global kGradientPaletteNum, pObjectNumber);    
  1460. end; # SetGradient()
  1461.  
  1462. #########################################################################
  1463. #            SetPaletteItem(pThePattern, pSelectPattern, pObjectNumber)
  1464. #========================================================================
  1465. # Author:        ML
  1466. # Description:    This is used when selecting an item from a palette. 
  1467. #                This task takes a palette item number as a parameter. If the palette item number
  1468. #                evaluates to 'Random' a palette item struct will be generated randomly.
  1469. #                If the pSelectPattern evaluates to true the palette item will also be selected.
  1470. #                Otherwise, the generated palette item struct will be returned without 
  1471. #                selecting the palette item.
  1472. # Parameters:    pPaletteItem - 0 - nothing done return 0
  1473. #                                - Valid Palette Item Num
  1474. #                                - valid Palette item struct
  1475. #                                - 'Random' - generates a random palette item struct
  1476. #                pSelectItem - Boolean flag which indicates whether or not to 
  1477. #                                select the palette item.
  1478. #                pPaletteName - string describing the name of the palette
  1479. #                pPaletteNum - the palette's position within the global gPaletteList
  1480. #                pObjectNumber - Integer used to track all elements that make up 
  1481. #                                an object - TCS related.
  1482. # Returns:        ItemStruct - A valid palette item struct
  1483. # Examples:        SetPaletteItem({ 8,3,"pattern" },0, "pattern", global kPatternPaletteNum);
  1484. # Assumptions:    All draw related data structures set up properly.
  1485. #========================================================================
  1486. # History:
  1487. #########################################################################
  1488. TASK SetPaletteItem(pPaletteItem := 'Random', pSelectItem := 1, pPaletteName:= "",
  1489.                     pPaletteNum:= 0, pObjectNumber := 0)    
  1490. begin
  1491.     if (global gDebugFlag)
  1492.     begin
  1493.         Println "++++++++ SetPaletteItem() has just been called for the {pPaletteName} palette +++++++++";
  1494.         Println "This is the palette item struct - ",pPaletteItem;
  1495.     end;
  1496.     global gPaletteList;
  1497.     if (gPaletteList) and (pPaletteNum)
  1498.     begin
  1499.         if (pPaletteItem)
  1500.         begin
  1501.             if(pPaletteItem = 'Random') # Random item
  1502.             begin                                
  1503.                 thePalette := gPaletteList[pPaletteNum];
  1504.                 pPaletteItem := GetRandomElement(thePalette);
  1505.             end;
  1506.             if (TypeOf(pPaletteItem) = 'integer')
  1507.                     ItemStruct := { pPaletteItem, pPaletteNum, "{pPaletteName}"};    # create a struct to send to the palette picker
  1508.             else
  1509.                 ItemStruct := pPaletteItem;
  1510.     
  1511.             if(ItemStruct) and (pSelectItem)
  1512.                 PalettePicker(ItemStruct, pObjectNumber);
  1513.         end;
  1514.         else
  1515.             ItemStruct := 0;
  1516.     end;
  1517.     else
  1518.     begin
  1519.         ItemStruct := 0;
  1520.         if (global gDebugFlag)
  1521.             Println "Either the gPaletteList or the {pPaletteName} palette is not defined";
  1522.     end;
  1523.     return(ItemStruct);
  1524. end; # SetPaletteItem()
  1525.  
  1526. #########################################################################
  1527. #                    CheckSetup()
  1528. #========================================================================
  1529. # Author:        KTA
  1530. # Description:    Reports the current state of various draw related
  1531. #                globals and global structures.  Call this task after a script    
  1532. #                has defined all of its draw related globals.  This routine will 
  1533. #                print the current setting.  A review of the output could help
  1534. #                to reveal any problems with the initial setup.
  1535. # Parameters:    none
  1536. # Returns:        nothing
  1537. # Examples:        CheckSetup();
  1538. #========================================================================
  1539. # History:
  1540. # KTA    7/18/94 changed the reporting so the current palette is 4 elements it is 
  1541. #                global coordinates and if 5 it is relative to the specified window
  1542. #########################################################################
  1543. TASK CheckSetup()
  1544. begin
  1545.     global kPalDocWind, kPalWind, kPopUpPal;
  1546.  
  1547.     Println "The Bounding Rect is - ", global gBoundingRect;        # Window inset
  1548.     Println "The Void Rect is - ", global gVoidRect;    # Rect not to draw in - coordinates should be RelativeToWindow
  1549.     Println "The Number of point that all multipoint object will be drawn is  - '{global gNumPoints}'";
  1550.     Println "The Global TextStr is - '{global gTextStr}'";
  1551.     For i := 1 to Card(global gPaletteList)
  1552.     begin 
  1553.         CurrentPalette := gPaletteList[i];
  1554.         Println;
  1555.         if (CurrentPalette[2] = kPopUpPal)
  1556.         begin
  1557.             PopPoint := {CurrentPalette[1][1],CurrentPalette[1][2]}; 
  1558.             Println "•• Palette number - '{i}' is a popup Palette with a poppoint at ",PopPoint;
  1559.             TLFirstElem := {CurrentPalette[1][3],CurrentPalette[1][4]}; 
  1560.             Println "•• The TopLeft of first elem is ",TLFirstElem;
  1561.             if (Card(CurrentPalette[1]) = 4)
  1562.                 Println "•• The popPoint and TopLeft are absolute coordinates";
  1563.             else if (Card(CurrentPalette[1]) = 5)
  1564.                 Println "•• The popPoint and TopLeft coordinates are relative to the specified window";
  1565.             Println "•• It is type - ",CurrentPalette[2], " which is a kPopUpPal ( pop up palette )";
  1566.         end;
  1567.         else if (CurrentPalette[2] = kPalWind)
  1568.         begin
  1569.             Println "•• Palette number - '{i}' has the specifier of - ",CurrentPalette[1][1];
  1570.             Println "•• It is type - ",CurrentPalette[2], " which is a kPalWind ( palette contained within its own window )";
  1571.             Println "•• The vertical distance between the top of the window and the top of the 1st tool is - ", CurrentPalette[1][2];
  1572.         end;
  1573.         else if (CurrentPalette[2] = kPalDocWind)
  1574.             Println "•• It is type - ",CurrentPalette[2], " which is a kPalDocWind ( contained within a documents window )";
  1575.         
  1576.         Println "•• The size of the Tool matrix is - ", CurrentPalette[3];
  1577.         Println "•• The Offset between tools is  - ", CurrentPalette[4];
  1578.  
  1579.         Struct := { 1, i, "FirstItem"};    # create a struct to send to the palette picker
  1580.         PalettePicker(Struct);
  1581.         FinalTool := CurrentPalette[3][1] * CurrentPalette[3][2];
  1582.         Struct := { FinalTool, i, "LastItem"};    # create a struct to send to the palette picker
  1583.         PalettePicker(Struct);
  1584.         Println;
  1585.     end;
  1586.     global gToolList;
  1587. end; # CheckSetup()
  1588.  
  1589. #########################################################################
  1590. #                    RandomDrawObject()
  1591. #========================================================================
  1592. # Author:        ML
  1593. # Description:    Generate a draw object with 'random' for all items.
  1594. # Parameters:    none
  1595. # Returns:        a draw object with 'random' for all items
  1596. # Examples:        RandomDrawObject();
  1597. #========================================================================
  1598. # History:
  1599. #########################################################################
  1600. TASK RandomDrawObject()
  1601. begin
  1602.     return ({'Random','Random','Random','Random','Random',
  1603.                 'Random','Random','Random','Random'});
  1604. end;